package com.mine.modules.vm.common.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

/**
 * @Author xu
 * @Date 2025/4/8
 **/
public class CustomConverter implements Converter<String> {

    @Override
    public Class<String> supportJavaTypeKey() {
        return String.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return null; // 关键：支持所有类型（包括空单元格）
    }

    @Override
    public String convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        System.out.println("cellData.getRowIndex()==1111"+cellData.getRowIndex());
        System.out.println("cellData.getType()==111"+cellData.getType());
        // 此时空单元格会进入此方法
        if (cellData.getType() == CellDataTypeEnum.EMPTY) {
            return "默认值";
        }
        return cellData.getStringValue();
    }

}
